package cn.wolfcode.wms.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Employee extends BaseDomain {

    private String name;

    private String password;

    private String email;

    private Integer age;

    private boolean admin;

    private Department dept;

    private List<Role> roles = new ArrayList<>();

    public String getRoleName() {
        if (this.admin) {
            return "超级管理员";
        }
        StringBuilder sb = new StringBuilder();
        if (this.getRoles().size() == 0) {
            return "普通用户";
        }
        for (Role role : roles) {
            sb.append(role.getName()).append(",");
        }
        sb.deleteCharAt(sb.length()-1);
        return sb.toString();
    }
}